package com.ourgame.tankgame.object;

import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.ourgame.tankgame.behavior.PhysicsBehavior;

/**
 *
 * @author L
 *
 */
public abstract class TankGameObject extends Node {

    private Spatial spatial;
    protected PhysicsBehavior physicsBehavior;

    public TankGameObject(Spatial spatial) {
        this.spatial = spatial;
        this.attachChild(spatial);
    }

    public Spatial getSpatial() {
        return spatial;
    }

    /**
     * 设置新物理行为
     * @param physicsBehavior 
     */
    public void setPhysicsBehavior(PhysicsBehavior physicsBehavior) {
        this.physicsBehavior = physicsBehavior;
    }

    /**
     * 执行物理行为
     */
    public void performPhysicsBehavior() {
        if (physicsBehavior != null) {
            physicsBehavior.performPhysicsBehavior();
        } else {
            throw new RuntimeException("未置设置具体的物理行为");
        }
    }
    
    
}
